﻿Imports DTO
Imports System.Data.SqlClient

Public Class NhomHangDAO
    Public Shared Function LayDSNhomHang() As DataTable
        Return CKetNoi.GetData("LayDSNhomHang")
    End Function

    Public Shared Function LayDSNhomHangCbx() As DataTable
        Return CKetNoi.GetData("select MaNhomHang, TenNhomHang from NhomHang")
    End Function

    Public Shared Function ThemNhomHang(nh As NhomHangDTO) As Integer
        Dim kt As Integer
        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@tenNH", nh.TenNhomHang))
        lst.Add(New SqlParameter("@maTT", nh.MaTrangThai))
        lst.Add(New SqlParameter("@ghichu", nh.GhiChu))
        kt = CKetNoi.ExecQueryStoreProc("ThemNhomHang", lst)
        Return kt
    End Function

    Public Shared Function CapNhatNhomHang(nh As NhomHangDTO) As Integer
        Dim kt As Integer
        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@maNH", nh.MaNhomHang))
        lst.Add(New SqlParameter("@tenNH", nh.TenNhomHang))
        lst.Add(New SqlParameter("@maTT", nh.MaTrangThai))
        lst.Add(New SqlParameter("@ghichu", nh.GhiChu))
        kt = CKetNoi.ExecQueryStoreProc("CapNhatNhomHang", lst)
        Return kt
    End Function

    Public Shared Function XoaNhomHang(nh As NhomHangDTO) As Integer
        Dim kt As Integer
        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@maNH", nh.MaNhomHang))
        kt = CKetNoi.ExecQueryStoreProc("XoaNhomHang", lst)
        Return kt
    End Function
End Class
